Paramiliar Design Studios Redefining Innovation and Excellence Design Services, website, build, cost effective, World Wide Web Consortium, browser compatability, website renovation

Client Login
Username
Password

Preventing Image Hot Linking and Stealing

Posted By : mattyb 30th Nov 2006

Preventing Image Hot Linking and Stealing

Believe it or not there are some people out there who, rather than developing their own content they prefer to steal yours.  This normally is a breach of copyright laws and is punishable but as you can guess, it is very hard to prove.
So how can you protect your website content from thieves?  Well sadly, it is impossible to stop, however you can help slow then down.

So why slow them down? Well this acts as a good deterrent also many thieves will steal your images by hot linking to them.

What is Hot Linking?

Dynamic pages SEOHot linking is a term used when one website shows an image that is stored on your website, in essence stealing your bandwidth, so not only are they stealing your image but also your bandwidth, which is just not acceptable.

Preventing Hot Linking with .htaccess

We will be using the power of the .htaccess file to achieve our goal.  With this amazing piece of code below, we can prevent people hot linking to our images while still allowing others to view them.  Remember if you already have a .htaccess file then you will need to add only a few lines, these lines are shown in more detail
Code
1.
2.
3.
4.
5.
6.
Options+FollowSymlinks
# no hot-linking script by Paramiliar.com
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?paramiliar\.com/ [nc]
RewriteRule .*\.(gif|jpg|png|jpeg)$ http://www.paramiliar.com/images/hotlink.jpg [nc]
Line 1 is always necessary in your .htaccess file, it informs Apache (the programme that acts as the web server) to follow any links it finds

Line 2 is just a description line of what the code is

Line 3 turns on the Rewrite Engine, this is what does the magic we need

Line 4 This is the first RewriteCond line (Rewrite Condition if you are wondering) this line allows direct requests to the file.

Line 5 This is the matching condition, this line means if the referrer sent by the website browser is Paramiliar.com then allow it access to the file requested.

Line 6 This is the line that stops others hot linking your files, this line tells apache that if none of the rules are met then they are not allowed to view any files that end with .gif, .jpg, .png or .jpeg and instead shows them the file hotlink.jpg which you can set to display a friendly message.

What if I already have a .htaccess file?

Well if you already have a .htaccess file then there are certain lines you need and some you don’t.  First off the very first line of your .htaccess file should always have the  Options+FollowSymlinks

After you have that on the first line all you need to do is use lines 3,4,5 and 6 in any location in your file so long as they are in the order shown in the code example.

So lets say you have a website called myaccess.com and you want to use this script, but you also want to give access to myaccess.co.uk to the images, then your .htaccess file would look something like this.
Code
1.
2.
3.
4.
5.
6.
7.
Options+FollowSymlinks
# no hot-linking script by Paramiliar.com
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?myaccess\.com/ [nc]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?myaccess\.co.uk/ [nc]
RewriteRule .*\.(gif|jpg|png|jpeg)$ http://www.myaccess.com/images/hotlink.jpg [nc]
And that’s all there is to it, I hope you have enjoyed this article as always if you have any questions simply leave a comment or drop us an email by using the contact us page.
Kind Regards
Matthew Bagley
Paramiliar Design Studios
http://www.paramiliar.com

AddThis Social Bookmark Button


Comments

There are no comments for this article, why not be the first to comment by filling in the form below!
:@ :) 8) :'( :)
:) :) :) :) :)
:) :) :) :) X(
Name
Website URL
Article Rating
1 bad , 5 good

1

2

3

4

5
Verification
Verification
Comments

Navigation

About Us
Free Articles
Testimonials
Privacy Statement
Design
Design Services
Design Pricing
Design Examples
Free Designs
Paid Designs
Website Design
Coding Services
Scripting Prices
Free Scripts
Paid Scripts
Request Scripting
Search Engines
What is SEO?
SEO Services
Pricing
Pay Per Click
Link Exchange
Request Optimisation
Request Advice
Portfolio
About the Company
Our Portfolio
Website Development
Website Applications
Graphic Design
Flash Design
View Clients
Services & Tools
Business Support
Services List
Who Is?
Sitemap Generator
Site Popularity Report

Members

Login

Latest Articles

FreeIndex - UK Web Designers Directory Resources - Link Exchange